package leetcode;

import java.util.HashMap;

/**
 * 描述:
 *
 * @author Madison You
 * @created 9:58
 */
public class Easy_1_TwoSum {

    public int[] twoSum(int[] nums, int target) {
        int[] temp = new int[2];
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            if (map.containsKey(nums[i])) {
                temp[0] = i;
                temp[1] = map.get(nums[i]);
                return temp;
            }
            map.put(target - nums[i], i);

        }
        return temp;
    }
}
